#include "FrontendState.h"

FrontendState::FrontendState (GameContext& gc) : GameState (gc)
{}
FrontendState::~FrontendState ()
{}

void FrontendState::Load ()
{
	mStartButton.Load         ("button_on.png", "button_off.png");
	mStartButton.SetPosition  (SVector2 (200.0f, 500.0f));
	mStartButton.SetText      ("Level1", 255, 255, 255);
	
	mStartButton2.Load        ("button_on.png", "button_off.png");
	mStartButton2.SetPosition (SVector2 (200.0f, 550.0f));
	mStartButton2.SetText     ("Level2", 255, 255, 255);

	mQuitButton.Load          ("button_on.png", "button_off.png");
	mQuitButton.SetPosition   (SVector2 (200.0f, 600.0f));
	mQuitButton.SetText       ("Quit", 255, 255, 255);

	mCursor.Load              ("sword.png");
	mFont.Load                (20);
}
void FrontendState::Unload ()
{
	mStartButton.Unload  ();
	mStartButton2.Unload ();
	mQuitButton.Unload   ();
	mCursor.Unload       ();
	mFont.Unload         ();
}
NextState FrontendState::Update (float deltaTime)
{
	mStartButton.Update  (deltaTime);
	mStartButton2.Update (deltaTime);
	mQuitButton.Update   (deltaTime);
	mCursor.Update       (deltaTime);

	NextState nextState = None;
	if (mStartButton.IsPressed ())
	{
		mGameContext.SetLevel (1);
		nextState = Gameplay;
	}
	else if (mStartButton2.IsPressed ())
	{
		mGameContext.SetLevel (2);
		nextState = Gameplay;
	}
	else if (mQuitButton.IsPressed ())
	{
		nextState = Quit;
	}

	return nextState;
}
void FrontendState::Render ()
{
	mFont.Print ("A Link to Pikachu's Past", 100, 100);

	mStartButton.Render  ();
	mStartButton2.Render ();
	mQuitButton.Render   ();
	mCursor.Render       ();
}